﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Template_Template : System.Web.UI.UserControl
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
        //This logic uses the DataAccess App instance to create a session variable that will stay in memory despite changes made during web postbacks
        //It also constructs the values for any Data Connections, and In-Memory tables used for the App instance of the DataAccess class.
        //The following logic should be standard so leave as is down to the next comment...
        if (!IsPostBack)
        {
        }
        else
        {
        }
        //Logic above should be left as-is

    }

    //EXPLANATION of how to use DataAccess Class
    //((DataAccess)Session["App"]).PutResult("ColumnName", "Data To Insert Into The In-Memory Table");  <<< This puts data into an in-memory table which waits for the ((DataAccess)Session["App"]).CommitCallData() command to write to the MSSQL database
    //((DataAccess)Session["App"]).PutCallData("ColumnName", "Data to Insert..."); <<< This puts data into an in-memory table which waits for the ((DataAccess)Session["App"]).CommitCallData() command to write to the MSSQL database
    //((DataAccess)Session["App"]).GetResult("ColumnName")  <<< gets a value from the in-memory result table which is populated at the first of the call and using ((DataAccess)Session["App"]).PutResult(...)
    //((DataAccess)Session["App"]).GetCallData("ColumnName") <<<  gets a value from the in-memory CallData table which is populated at the first of the call and using ((DataAccess)Session["App"]).CallData(...)
    //((DataAccess)Session["App"]).GetDNIS("ColumName") <<< gets a value from the DNIS table which matches the current call DNIS
    //YourDataSource = ((DataAccess)Session["App"]).GetUsercodes() <<< Returns a Data source of the usercodes for the current project so it can be used in controls



    //POST LOGIC - For Step or Start pages
    //Add if statements as you add pages
    //For Next and Finish pages it is best to use the index in the if statements as below
    protected void WebWizard_NextButtonClick(object sender, WizardNavigationEventArgs e)
    {

        int page = WebWizard.ActiveStepIndex;
        if (page == WebWizard.WizardSteps.IndexOf(this.Intro))
        {
            return;
        }

        if (page == WebWizard.WizardSteps.IndexOf(this.StepPageID))
        {
            //This Switch is a sample only Please modify or delete as needed.
            switch (radioMenu.SelectedValue.ToString())
            {
                case "1":
                    WebWizard.ActiveStepIndex = WebWizard.WizardSteps.IndexOf(Intro);
                    break;
                case "2":
                    WebWizard.ActiveStepIndex = WebWizard.WizardSteps.IndexOf(StepPageID);
                    break;
                case "3":
                    WebWizard.ActiveStepIndex = WebWizard.WizardSteps.IndexOf(FinishPageID);
                    break;
                case "4":
                    WebWizard.ActiveStepIndex = WebWizard.WizardSteps.IndexOf(Disposition);
                    break;
                default:
                    WebWizard.ActiveStepIndex = WebWizard.WizardSteps.IndexOf(Intro);
                    break;
            }
            return;

        }

        if (page == WebWizard.WizardSteps.IndexOf(this.FinishPageID))
        {
            return;
        }
        if (page == WebWizard.WizardSteps.IndexOf(this.Disposition))
        {
            return;
        }



    }

    //POST LOGIC for disposition pages
    //this is for pages that contain a disposition button
    protected void WebWizard_FinishButtonClick(object sender, WizardNavigationEventArgs e)
    {

        int page = WebWizard.ActiveStepIndex;
        if (page == WebWizard.WizardSteps.IndexOf(this.Intro))
        {
            return;
        }
        if (page == WebWizard.WizardSteps.IndexOf(this.StepPageID))
        {
            return;
        }
        if (page == WebWizard.WizardSteps.IndexOf(this.FinishPageID))
        {
            //Change These two lines of code - For Information Only

            ((DataAccess)Session["App"]).PutCallData("webusercode", "R3");
            WebWizard.ActiveStepIndex = WebWizard.WizardSteps.IndexOf(this.Disposition);
            return;
        }
        if (page == WebWizard.WizardSteps.IndexOf(this.Disposition))
        {
            return;
        }


    }

    //PRE-LOGIC
    //Add if statements as needed for post-logic
    //You can use the Step ID name instead of the index as used in Next and Finish logic.
    protected void WebWizard_ActiveStepChanged(object sender, EventArgs e)
    {
        if (WebWizard.ActiveStep.Title.ToString() == "Disposition")
        {
            //These two lines should be fairly standard - they write the in-memory tables to the Database
            ((DataAccess)Session["App"]).CommitCallData();
            return;
        }

    }
}